from flask import Flask
from configs import config  # 导入配置文件
from .extensions import register_extensions
from .view import register_views
from .apis import register_apis



def create_app(config_name='dev'):
    app = Flask('pear-flask')
    # print(config[config_name])

    app.config.from_object(config[config_name])  # 加载配置文件
    # print(app.config.get("ROOT_PATH"))
    register_extensions(app)
    register_views(app)
    register_apis(app)

    # @app.route("/")
    # def index():
    #     return "hello pear-admin-flask !"

    return app
